#ifndef _SERVER_H_
#define _SERVER_H_

#include <iostream>
using namespace std;
#include <WinSock2.h>
#include <string.h>
#include <time.h>

/* DEFINES */
#define HTTP_PORT 8080
#define MAX_SOCKETS 50
#define TIMEOUT 60

#define BUFFER_SIZE 8192

#define EMPTY 0
#define LISTEN 1
#define RECEIVE 2
#define IDLE 4
#define SEND 8

/* STRUCT */
struct SocketState
{
	SOCKET id;
	int recv;
	int send;
	char buffer[BUFFER_SIZE];
	int len;
	char* file;
	long fileSize;
	time_t lastTransmission;
};

/* GLOBALS */
extern struct SocketState sockets[MAX_SOCKETS];

/* FUNCTIONS */
void initServer();

void printAddressPort(int i_Index);

bool addSocket(SOCKET id, int type);

void removeSocket(int index);

void sendMessage(int id);

void receiveMessage(int i_Index);

void acceptConnection(int index);

int HandleRequest(int i_Index);

void timeOutRemover();

void printCurrentSockets();

#endif